package com.trkj.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
@Slf4j
public class Zy2 {
    public Object aroundCall(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("来电显示");

        long startTime = System.currentTimeMillis();
        Object result = joinPoint.proceed(); // 调用原始方法
        long endTime = System.currentTimeMillis();

        long duration = endTime - startTime;
        System.out.println("通话时长：" + duration + "毫秒");

        return result;
    }

    public Object aroundSendMessage(ProceedingJoinPoint joinPoint) throws Throwable {
        Object[] args = joinPoint.getArgs(); // 获取目标方法的参数列表

        // 假设第一个参数是 receiver，第二个参数是 message
        if (args.length >= 2 && args[0] instanceof String && args[1] instanceof String) {
            String receiver = (String) args[0];
            String message = (String) args[1];

            log.debug("接收者：" + receiver);
            log.debug("输入信息内容：" + message);
        }

        Object result = joinPoint.proceed(); // 调用原始方法

        return result;
    }

}
